Skip to content

Use smooth norm and sqrt#240

Open
1-Bart-1 wants to merge 7 commits into
mainfrom
smooth
Open

Use smooth norm and sqrt#240
1-Bart-1 wants to merge 7 commits into
mainfrom
smooth

Conversation

@1-Bart-1
Copy link
Copy Markdown
Member

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Member

@ufechner7 ufechner7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is smooth_norm3 defined?
And why do you want to use it in the first place?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces the strict norm3/normalize3! helpers with smoothed variants (smooth_norm3(a) = sqrt(a·a + 1e-12), unconditional smooth_normalize3!) throughout the filament induced-velocity routines, the 2D bound velocity, calculate_results, find_center_of_pressure, and solve!'s force-direction normalization, and bumps the additive epsilon inside smooth_sqrt from 1e-30 to 1e-18. The intent is to remove singular NaN/Inf results at on-axis or zero-magnitude geometries.

Changes:

  • Switch all filament norm3/normalize3! call sites to the smoothed helpers and remove the explicit vel .= 0.0 near-axis branches in the bound and semi-infinite trailing routines (the finite trailing routine retains it).
  • Update calculate_results, find_center_of_pressure, calculate_velocity_induced_bound_2D!, and solve! to use the smoothed helpers; loosen smooth_sqrt epsilon in the gamma update.
  • Adjust the semi-infinite filament "Point on Filament" test to expect isfinite instead of isnan, and relax moment_dist[1] tolerance in the body-aerodynamics test from 1e-8 to 1e-7.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/filament.jl Replaces norm3/normalize3! with smoothed versions, removes near-axis zeroing in bound and semi-infinite routines.
src/body_aerodynamics.jl Uses smooth_norm3 in calculate_results and find_center_of_pressure, including in pre-existing zero-magnitude guards.
src/panel.jl Switches the 2D bound induced velocity to smoothed norms.
src/solver.jl Uses smooth_normalize3! for force-direction unit vectors and increases smooth_sqrt epsilon to 1e-18.
test/filament/test_semi_infinite_filament.jl Updates singular-start-point expectation from NaN to finite.
test/body_aerodynamics/test_body_aerodynamics.jl Relaxes moment_dist[1] tolerance to 1e-7.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/body_aerodynamics.jl
Comment on lines 827 to 847
@@ -833,7 +833,7 @@ function calculate_results(
va_ref_vector[k] = va_ref_vector[k] / direction_norm *
reference_speed
end
va_ref_mag = norm3(va_ref_vector)
va_ref_mag = smooth_norm3(va_ref_vector)
va_ref_mag > 0.0 || throw(ArgumentError(
"Reference freestream magnitude must be positive."))
va_ref_unit = body_aero.work_vectors[1]
@@ -843,7 +843,7 @@ function calculate_results(
end
dir_lift_ref = body_aero.work_vectors[2]
cross3!(dir_lift_ref, va_ref_vector, spanwise_direction)
dir_lift_ref_norm = norm3(dir_lift_ref)
dir_lift_ref_norm = smooth_norm3(dir_lift_ref)
dir_lift_ref_norm > 0.0 || throw(ArgumentError(
Comment thread src/filament.jl
Comment on lines +327 to 331
@inline function smooth_normalize3!(v)
n = smooth_norm3(v)
v[1] /= n; v[2] /= n; v[3] /= n
nothing
end
Comment thread src/filament.jl
Comment on lines 75 to 81
if nr1Xr0 / nr0 > epsilon
nr1Xr2 = norm3(r1Xr2)
nr1Xr2 = smooth_norm3(r1Xr2)
coeff = (gamma / (4π)) / (nr1Xr2^2) * dot3(r0, r1r2norm)
@inbounds for k in 1:3
vel[k] = coeff * r1Xr2[k]
end
elseif nr1Xr0 / nr0 < 1e-12 * epsilon
vel .= 0.0
else
@1-Bart-1
Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants